package com.industry.system.controller;

import com.industry.framework.common.Result;
import com.industry.framework.common.page.PageQuery;
import com.industry.framework.common.page.TableDataInfo;
import com.industry.system.controller.vo.SystemUserRespVO;
import com.industry.system.dal.dataobject.SystemUser;
import com.industry.system.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("query-system-user-list")
    public Result<TableDataInfo<SystemUser>> querySystemUserList(PageQuery pageQuery){
        return Result.success(userService.getAllSystemCodes(pageQuery));
    }

    @GetMapping("/query-system-user-byId")
    public Result<SystemUserRespVO> querySystemUserById(@RequestParam("userId") String userId){
        return Result.success(userService.querySystemUserById(userId));
    }

    @PostMapping("/insert")
    public Result<String> insert(@RequestBody SystemUser user){
        return userService.insert(user) > 0 ? Result.success("success") : Result.fail("fail");
    }


    @PostMapping("/modify")
    public Result<String> modify(@RequestBody SystemUserRespVO user){
        return userService.modify(user) > 0 ? Result.success("success") : Result.fail("fail");
    }
}
